home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 201-225 / disk_221 / iffm2 / iffm2.def < prev    next >
Text File  |  1992-05-06  |  9KB  |  229 lines

  1. DEFINITION MODULE IFFM2;
  2.  
  3.  
  4. (*
  5.   ===========================================================================
  6.   ||                                                                       ||
  7.   ||   IFFM2 - Amiga (r) version                                           ||
  8.   ||                                                                       ||
  9.   ||   Original Developers:  November 15, 1988, Greg Epley                 ||
  10.   ||                                                                       ||
  11.   ||    Module Version:  *   1.0.0, May 29, 1989, Greg Epley               ||
  12.   ||                         First implementation; compiled with M2AMIGA   ||
  13.   ||                         Rel. 3.1                                      ||
  14.   ||                                                                       ||
  15.   ||                                                                       ||
  16.   ||              Copyright (c) 1988, 1989  Second Sight (tm)              ||
  17.   ||                                                                       ||
  18.   ||    Amiga is a registered trademark of Commodore-Amiga, Inc.  Second   ||
  19.   ||    Sight is a trademark of Second Sight, Lexington, North Carolina.   ||
  20.   ||                                                                       ||
  21.   ===========================================================================
  22. *)
  23.  
  24. (*
  25. =================================  IMPORTS  =================================
  26. *)
  27. FROM DOS    IMPORT FileHandlePtr;
  28. FROM Exec    IMPORT UByte;
  29. FROM Graphics    IMPORT BitMapPtr,
  30.                        ViewModes, ViewModeSet;
  31.  
  32.  
  33. (* NOTE: Heap routines are used to dynamically allocate memory space by
  34.  * some of the IFFM2 routines.  Even if the client program should lose
  35.  * control this memory will be returned to the system unless a fatal
  36.  * M2Amiga crash occurs (in which case it doesn't matter anyway, since
  37.  * you have to re-boot).  Also, in case you don't know this, the user of
  38.  * these routines is "the Client". *)
  39.  
  40.  
  41. TYPE
  42.   (* IFF id's are stored as LONGINT types for efficient copy and compare. *)
  43.   ID = LONGINT;
  44.  
  45. CONST
  46.   (* These are shifting constants used to define the LONGINT IFF id's. *)
  47.   H = 1000000H;  M = 10000H;  L = 100H;  V = 10H;
  48.  
  49.   (* These LONGINT IFF id's are currently recognized by the IFF routines in
  50.    * this module. *)
  51.   IDFORM = ID("F")*H + ID("O")*M + ID("R")*L + ID("M");
  52.   IDILBM = ID("I")*H + ID("L")*M + ID("B")*L + ID("M");
  53.   IDBMHD = ID("B")*H + ID("M")*M + ID("H")*L + ID("D");
  54.   IDCMAP = ID("C")*H + ID("M")*M + ID("A")*L + ID("P");
  55.   IDBODY = ID("B")*H + ID("O")*M + ID("D")*L + ID("Y");
  56.   IDCAMG = ID("C")*H + ID("A")*M + ID("M")*L + ID("G");
  57.   IDEOFX = ID("E")*H + ID("O")*M + ID("F")*L + ID("X");
  58.  
  59. CONST
  60.   (* The maximum number of color registers allowed on the Amiga. *)
  61.   MaxColorRegister = 64;
  62.   
  63. TYPE
  64.   (*---- BitMapHeader -----------------------------------------------------*)
  65.   (* The BitMapHeader structure is specifically an IFF ILBM structure. *)
  66.  
  67.   (* Type of masking for the data. *)
  68.   Masking = (mskNone, mskHasMask, mskHasTransparentColor, mskLasso);
  69.  
  70.   (* Type of compression for the data. *)
  71.   Compression = (cmpNone, cmpByteRun1);
  72.  
  73.   (* The BitMapHeader structure stores assorted information from an IFF ILBM
  74.    * BMHD (BitMapHeaDer) chunk. *)
  75.   BitMapHeader = RECORD
  76.     w, h : CARDINAL;
  77.     x, y : INTEGER;
  78.     nPlanes : UByte;
  79.     masking : Masking;
  80.     compression : Compression;
  81.     pad1 : UByte;
  82.     transparentColor : CARDINAL;
  83.     xAspect, yAspect : UByte;
  84.     pageWidth, pageHeight : INTEGER;
  85.   END;
  86.   BitMapHeaderPtr = POINTER TO BitMapHeader;
  87.  
  88.  
  89.   (* The IFFFileFrame structure stores assorted information related to each
  90.    * IFF file using the IFFM2 routines.  Every item in this structure may
  91.    * not be used for every type of IFF file so pointer types are used for
  92.    * most of the items to cut down on wasted space.  The frame space is
  93.    * allocated during OpenIFF() and freed by CloseIFF(). *)  
  94.   
  95.   IFFFileFrame = RECORD
  96.     filehandle : FileHandlePtr;
  97.     bmhd : BitMapHeaderPtr;
  98.     cmap : ARRAY [0..MaxColorRegister-1] OF INTEGER;
  99.     nColors : INTEGER;
  100.     bitmap : BitMapPtr;
  101.     camg : ViewModeSet;
  102.   END;
  103.   IFFFileFramePtr = POINTER TO IFFFileFrame;
  104.  
  105.  
  106. (*---- OpenIFF ------------------------------------------------------------*)
  107. (*
  108.  * Open an IFF file for reading or writing and return an IFFFileFramePtr if
  109.  * successful or NIL if not.
  110.  *
  111.  * The mode indicates whether to read [DOS oldFile] or write [DOS newFile].
  112.  * This also pre-initializes all the other frame items; it does not allocate
  113.  * any memory spaces for them but just sets such pointers to NIL.
  114.  *)
  115. PROCEDURE OpenIFF (name : ARRAY OF CHAR; mode : LONGINT) : IFFFileFramePtr;
  116.  
  117.  
  118. (*---- CloseIFF -----------------------------------------------------------*)
  119. (*
  120.  * Close an IFF file previously opened with OpenIFF().  This also deallocates
  121.  * any memory spaces which were dynamically allocated by IFFM2 calls.
  122.  *)
  123. PROCEDURE CloseIFF (VAR frame : IFFFileFramePtr);
  124.  
  125.  
  126. (*---- PrintIFFError ------------------------------------------------------*)
  127. (*
  128.  * Print a text error message to the M2Amiga standard output stream used by
  129.  * Terminal.  Safe to call even if there is no error.
  130.  *)
  131. PROCEDURE PrintIFFError ();
  132.  
  133.  
  134. (*---- GetType ------------------------------------------------------------*)
  135. (*
  136.  * Read the IFF file type chunk (e.g., ILBM, SMUS, 8SVX, ANIM, etc.) and
  137.  * return to the client as an ID.  This will not return any types not
  138.  * currently supported.
  139.  *)
  140. PROCEDURE GetType (frame : IFFFileFramePtr) : ID;
  141.  
  142.  
  143. (*---- GetChunkHdr --------------------------------------------------------*)
  144. (*
  145.  * Read an IFF file data chunk (e.g., BMHD, CMAP, BODY) and return its size
  146.  * and ID to the client.
  147.  *)
  148. PROCEDURE GetChunkHdr (VAR frame : IFFFileFramePtr; VAR size : LONGINT) : ID;
  149.  
  150.  
  151. (*---- GetPad -------------------------------------------------------------*)
  152. (*
  153.  * Read an IFF file pad byte.  Returns TRUE to client if successful, FALSE
  154.  * if not.
  155.  *)
  156. PROCEDURE GetPad (frame : IFFFileFramePtr) : BOOLEAN;
  157.  
  158.  
  159. (*---- GetUnknown ---------------------------------------------------------*)
  160. (*
  161.  * Read an unrecognized IFF file data chunk and return TRUE if successful or
  162.  * FALSE if not.
  163.  *)
  164. PROCEDURE GetUnknown (frame : IFFFileFramePtr; size : LONGINT) : BOOLEAN;
  165.  
  166.  
  167. (*==== ILBM Standard Reader Routines ======================================*)
  168. (*
  169.  * For standard ILBM files the following allocations and items are filled for
  170.  * you by calling the indicated routines:
  171.  *
  172.  *    filehandle    - filled by OpenIFF() if successful
  173.  *    bmhd        - structure space allocated and filled by GetBMHD(),
  174.  *                        also assumes display viewmodes (camg) if CAMG chunk
  175.  *                        not found yet [reads]; freed during CloseIFF()
  176.  *    cmap        - ARRAY of INTEGER RGB color values (about 120 bytes
  177.  *                        of static storage by GetCMAP() [reads]
  178.  *      nColors         - INTEGER 15-bits of static storage by GetCMAP()
  179.  *              [reads]
  180.  *    camg        - ViewModeSet space elements are set during
  181.  *              GetCAMG() [reads]
  182.  *
  183.  * Client must allocate and fill the following items [as needed]:
  184.  *
  185.  *    bitmap        - pointer to a BitMap structure BEFORE calling
  186.  *              GetBODY() [reads] *)
  187.  
  188. (*---- GetBMHD ------------------------------------------------------------*)
  189. (*
  190.  * Read an IFF ILBM BMHD (BitMapHeaDer) chunk; dynamically allocates the
  191.  * bmhd data space and fills it; also guesses at the display viewmodes if
  192.  * the CAMG chunk hasn't been found yet.  Returns TRUE to client if
  193.  * successful or FALSE if not.
  194.  *)
  195. PROCEDURE GetBMHD (VAR frame : IFFFileFramePtr; size : LONGINT) : BOOLEAN;
  196.  
  197.  
  198. (*---- GetCMAP ------------------------------------------------------------*)
  199. (*
  200.  * Read an IFF ILBM CMAP (ColorMAP) chunk; also sets a count of the number
  201.  * of colors in the color map chunk; refer to the frame's cmap entry for
  202.  * the format of the final contents after reading.  Returns TRUE to client if
  203.  * successful or FALSE if not.
  204.  *)
  205. PROCEDURE GetCMAP (VAR frame : IFFFileFramePtr; size : LONGINT) : BOOLEAN;
  206.  
  207.  
  208. (*---- GetBODY ------------------------------------------------------------*)
  209. (*
  210.  * Read an IFF ILBM BODY (bitplane data) chunk; this handles bitplane data
  211.  * with compression and/or masking applied; client should point the frame's
  212.  * bitmap item to a valid BitMap data space before calling this.  Returns
  213.  * TRUE to client if successful or FALSE if not.
  214.  *)
  215. PROCEDURE GetBODY (VAR frame : IFFFileFramePtr; size : LONGINT) : BOOLEAN;
  216.  
  217.  
  218. (*---- GetCAMG ------------------------------------------------------------*)
  219. (*
  220.  * Read an IFF ILBM CAMG (Commodore-AMiGa viewmodes) chunk; this translates
  221.  * the LONGINT numeric for the viewmodes and sets the proper elements in the
  222.  * frame's camg data space.  Returns TRUE to client if successful or FALSE
  223.  * if not.
  224.  *)
  225. PROCEDURE GetCAMG (VAR frame : IFFFileFramePtr; size : LONGINT) : BOOLEAN;
  226.  
  227.  
  228. END IFFM2.
  229.